# -*- encoding: utf-8 -*-
'''
@File    :   visual.py
@Time    :   2023/02/13 17:21:36
@Author  :   hgy_rick
@Description : 
'''
from ..Exception.Python.BasicException import *
import matplotlib.pyplot as plt

'''
@sp_size: subplot size, list, if empty, use figure
@x: x axis, list
@y: y axis, list
@legend: list
@title: figure title
'''
def drawCurves(sp_size, x, y, legend, title):
    if not len(x) == len(y) == len(legend):
        raise ExpectEqualException("list x, y, legend should be the same size!")

    if len(sp_size) == 0:
        plt.figure()
    else:
        plt.subplot(*sp_size)
    
    plt.title(title)
    
    for i in range(len(x)):
        plt.plot(x[i], y[i], label=legend[i])
    
    plt.legend()
    plt.grid(True)